<template>
	<view>
		 
		<view class="errormsgDiv" v-if="nodata">
			<view class="errormsg">\（￣︶￣）/</view>
			<view class="errormsg2">没有相关数据</view>
		</view>
		<view v-else>

			<view class="cu-list menu">
				
				<navigator class="cu-item " :key="index" v-for="(item,index) in bills_list"  :data-index="index" :url="'/pages/bills/bill_detail?id='+item.bill_entry_id">
					<view class="content padding-tb-sm">
						<view>{{item.cost_type}}</view>
						<view class="text-gray text-sm">
							{{item.paytime}}</view>
					</view>
					<view class="action">
						<checkbox-group>
							<view class="cu-form-group">
								<view class="cu-tag round bg-orange light">￥{{item.bill_entry_amount}}</view>
								<!-- <checkbox style="margin-left:10px" :class="checkbox[index]?'checked':''" :checked="checkbox[index]?true:''"></checkbox> -->
							</view>
						</checkbox-group>
					</view>
				</navigator>
				
			</view>
			<view style="height: 120upx;"></view>
			

		</view>
	</view>
</template>


<script>
	import beeApp from '../../beeApp.js'
	export default {
		data() {
			return {
				checkbox: {

				},
				loadding: 0,
				selectAllcheckbox: false,
				user_info: {
					community: {},
					tenement_type: []
				},

				page: 1,
				lastPage: 0,
				mounted: 0,
				room_info: {},
				showNoData: 0,
				bills_list: [],
				bill_amount: "0.00",
				out_room_id: '',
				community_id: '',
				nodata: 0,
			}
		},
		onLoad(option) {
			// this.out_room_id = option.out_room_id ? option.out_room_id : uni.getStorageSync("out_room_id");
			// this.community_id = option.community_id ? option.community_id : uni.getStorageSync("community_id");
			// if (!this.out_room_id) {
			// 	uni.navigateTo({
			// 		url: '/pages/bills/getOutRoomId'
			// 	})
			// 	return;
			// }
			this.load();

		},

		onShow: function() {
			var reload = beeApp.getPageData("pages/bills/bills", "reload");
			if (reload == 1) {
				this.out_room_id = uni.getStorageSync("out_room_id");
				this.community_id = uni.getStorageSync("community_id");
				beeApp.setPageData("pages/bills/bills", {
					reload: 0
				});
				this.load(1);
			}
		},
		onReachBottom() {
			this.getBillList();
		},
		onPullDownRefresh() {
			this.load(1);
			uni.stopPullDownRefresh();
		},
		methods: {
			load: function(reload = 0) {
				// this.getRoomInfo(reload);
				// this.getUserInfo(reload);
				beeApp.getUserInfo((userInfo)=>{
					this.user_info = userInfo;
					this.getBillList(reload);
				})
				
			},
			
			getBillList: function(reload = 0) {
				// var out_room_id = this.out_room_id;
				var that = this;
				if(reload==1){
					that.bills_list = [];
					that.loadding=0;
					that.lastPage=0;
				}
				if(that.loadding==1){
					return;
				}
				
				that.loadding = 1;
				beeApp.api("/api/community_bills/get", {
					// community_id: this.community_id,
					pay_user_id: this.user_info.user_id,
					status: 1,
					order:"bill_entry_id desc"
				}, function(res) {
					that.loadding = 0;
					if (res.code != 200) {
						beeApp.alert(res.msg);
						return;
					}
					if(res.data.list.length==0){
						that.lastPage = 1;
					}
					that.bills_list = that.bills_list.concat(res.data.list) ;
					if (that.bills_list.length === 0) {
						that.nodata = 1;
					}
				});
			},


			setData: function(data) {
				for (var i in data) {
					this[i] = data[i];
				}
			},
		}
	}
</script>


<style>
	.selectAllBox {
		float: left;
		width: 200upx;
	}

	.selectAllBox .cu-form-group {
		margin-top: 10upx;
	}

	.selectAllBox .cu-form-group .title {
		padding-right: 0
	}

	.postOrderBox {
		float: right;
		min-width: 500upx;
	}

	.fixed-btn {
		background: #fff;
	}

	.postOrderBox button {
		border-radius: 0;
		height: 120upx;
		font-size: 40upx;
	}

	.cu-list.menu>.cu-item {
		padding-right: 0px;
	}
</style>
